home *** CD-ROM | disk | FTP | other *** search
/ Word Perfect Main Street:…th Treasure of the Tombs / WordPerfect Main Street - Memphis Math Treasure of the Tombs.iso / setup.mst < prev    next >
Text File  |  1994-08-26  |  15KB  |  536 lines

  1. '**************************************************************************
  2. '*                       Memphis Math Installation and Setup
  3. '**************************************************************************
  4.  
  5. '$INCLUDE 'setupapi.inc'
  6. '$INCLUDE 'msdetect.inc'
  7.  
  8. ''Dialog ID's
  9. CONST ASKQUIT      = 200
  10. CONST DESTPATH     = 300
  11. CONST EXITFAILURE  = 400
  12. CONST EXITQUIT     = 600
  13. CONST EXITSUCCESS  = 700
  14. CONST OPTIONS      = 800
  15. CONST APPHELP      = 900
  16. CONST CUSTINST     = 6200
  17. CONST TOOBIG       = 6300
  18. CONST BADPATH      = 6400
  19.  
  20. ''Windows API include stuff
  21. CONST SW_SHOWMAXIMIZED = 3
  22.  
  23. DECLARE FUNCTION ShowWindow  LIB "user.exe" (hWnd%, iShow%) AS INTEGER
  24.  
  25. ''Bitmap ID
  26. CONST LOGO         = 1
  27.  
  28. ''File Types
  29. CONST MINIMAL      = 1
  30. CONST STANDARD     = 2
  31. CONST FULL         = 3
  32.  
  33. GLOBAL DEST$        ''Destination directory.
  34. GLOBAL RESDIR$            ''Resource files subdirectory.
  35. GLOBAL APPDIR$            ''Application files subdirectory
  36. GLOBAL DATADIR$            ''Data files subdirectory
  37. GLOBAL CTL3DDIR$        ''CTL3D source subdirectory
  38. GLOBAL SOURCE$            ''Source directory.
  39. GLOBAL PMGROUP$            ''Program manager group title
  40. GLOBAL WINDRIVE$    ''Windows drive letter.
  41. GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  42. GLOBAL OPT2OPT$     ''Option selection from OptFiles2 option dialog.
  43.  
  44. ''CustInst list symbol names
  45. GLOBAL APPNEEDS$    ''Option list costs per drive
  46. GLOBAL RESNEEDS$
  47. GLOBAL REQNEEDS$
  48. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  49. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  50.  
  51. ''Dialog list symbol names
  52. GLOBAL CHECKSTATES$
  53. GLOBAL STATUSTEXT$
  54. GLOBAL DRIVETEXT$
  55.  
  56.  
  57. DECLARE SUB AddFilesToCopyList (ftype%)
  58. DECLARE SUB RecalcOptFiles (ftype%)
  59. DECLARE SUB RecalcPath
  60. DECLARE SUB SetDriveStatus
  61. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  62.  
  63. INIT:
  64.  
  65.         ''Maximize window
  66.         i1% = ShowWindow (HwndFrame (), SW_SHOWMAXIMIZED)
  67.  
  68.         ''initialize global variables
  69.         WINDRIVE$ = MID$ (GetWindowsDir, 1, 1)
  70.         SOURCE$ = GetSymbolValue ("STF_SRCDIR")
  71.         DEST$ = "C:\MEMPHIS"                                            ''default destination directory
  72.         RESDIR$ = "RESOURCE"                                            ''Resource files subdirectory.
  73.         APPDIR$ = ""                                                            ''Application files subdirectory
  74.         CTL3DDIR$ = "CTL3D"                                                ''CTL3D source subdirectory
  75.         DATADIR$ = "DATA"                                                    ''Data files subdirectory
  76.         PMGROUP$ = "WordPerfect Main Street"
  77.         CUIDLL$ = "mscuistf.dll"                           ''custom user interface dll
  78.         HELPPROC$ = "FHelpDlgProc"                      ''Help dialog procedure
  79.  
  80.         SetBitmap CUIDLL$, LOGO
  81.         SetTitle "Memphis Math Treasure of the Tombs Installation"
  82.  
  83.         szInf$ = GetSymbolValue("STF_SRCINFPATH")
  84.         IF szInf$ = "" THEN
  85.                 szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  86.         END IF
  87.         ReadInfFile szInf$
  88.  
  89.  
  90.         ''determine version requirements
  91.         MajorVer% = GetWindowsMajorVersion()
  92.         MinorVer% = GetWindowsMinorVersion()
  93.         IF MajorVer% < 3 OR (MajorVer% = 3 AND MinorVer% < 10) THEN
  94.             i% = DoMsgBox ("Microsoft Windows version 3.10 or greater is required for this software.  Please upgrade your version of Windows.", "Memphis Math Install", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  95.             END
  96.         END IF
  97.  
  98.         ''CustInst list symbols
  99.         CHECKSTATES$ = "CheckItemsState"
  100.         STATUSTEXT$  = "StatusItemsText"
  101.         DRIVETEXT$   = "DriveStatusText"
  102.  
  103.         AddListItem CHECKSTATES$, "ON"
  104.         AddListItem CHECKSTATES$, "OFF"
  105.         AddListItem CHECKSTATES$, "OFF"
  106.  
  107.         FOR i% = 1 TO 3 STEP 1
  108.                 AddListItem STATUSTEXT$, ""
  109.         NEXT i%
  110.         FOR i% = 1 TO 7 STEP 1
  111.                 AddListItem DRIVETEXT$, ""
  112.         NEXT i%
  113.         ReplaceListItem DRIVETEXT$, 7, DEST$
  114.  
  115.         ''Disk cost list symbols
  116.         APPNEEDS$   = "AppNeeds"
  117.         RESNEEDS$   = "ResourceNeeds"
  118.         REQNEEDS$   = "RequiredNeeds"
  119.         EXTRACOSTS$ = "ExtraCosts"
  120.         BIGLIST$    = "BigList"
  121.         FOR i% = 1 TO 3 STEP 1
  122.                 AddListItem BIGLIST$, ""
  123.         NEXT i%
  124.         FOR i% = 1 TO 26 STEP 1
  125.                 AddListItem EXTRACOSTS$, "0"
  126.         NEXT i%
  127.  
  128.         ''File Option Variables
  129.         OPT1OPT$ = "1"
  130.         OPT2OPT$ = "1"
  131.  
  132.         RecalcPath
  133.         SetDriveStatus
  134.  
  135. '$IFDEF DEBUG
  136.         i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  137. '$ENDIF ''DEBUG
  138.  
  139.  
  140.  
  141. CUSTINST:
  142.         sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  143.  
  144.         IF sz$ = "CONTINUE" THEN
  145.                 ''Install only if it will fit.
  146.                 FOR i% = 1 TO 3 STEP 1
  147.                         IF GetListItem(BIGLIST$, i%) <> "" THEN
  148.                                 GOSUB TOOBIG
  149.                                 GOTO CUSTINST
  150.                         END IF
  151.                 NEXT i%
  152.                 UIPop 1
  153.                 GOTO INSTALL
  154.         ELSEIF sz$ = "PATH" THEN
  155.                 GOTO GETPATH
  156.         ELSEIF sz$ = "CHK1" THEN
  157.                 RecalcPath
  158.                 RecalcOptFiles MINIMAL
  159.                 SetDriveStatus
  160.                 GOTO CUSTINST
  161.         ELSEIF sz$ = "CHK2" THEN
  162.                 RecalcPath
  163.                 RecalcOptFiles STANDARD
  164.                 SetDriveStatus
  165.                 GOTO CUSTINST
  166.         ELSEIF sz$ = "CHK3" THEN
  167.                 RecalcPath
  168.                 RecalcOptFiles FULL
  169.                 SetDriveStatus
  170.                 GOTO CUSTINST
  171.         ELSEIF sz$ = "REACTIVATE" THEN
  172.                 RecalcPath
  173.                 SetDriveStatus
  174.                 GOTO CUSTINST
  175.         ELSE
  176.                 GOSUB ASKQUIT
  177.                 GOTO CUSTINST
  178.         END IF
  179.  
  180.  
  181.  
  182. INSTALL:
  183.         ''Create directory structure
  184.         CreateDir DEST$, cmoNone            ''root
  185.  
  186.         SubDir$ = MakePath (DEST$, APPDIR$)
  187.         CreateDir SubDir$, cmoNone        ''application
  188.  
  189.         SubDir$ = MakePath (DEST$, RESDIR$)
  190.         CreateDir SubDir$, cmoNone        ''resource
  191.  
  192.         SubDir$ = MakePath (DEST$, DATADIR$)
  193.         CreateDir SubDir$, cmoNone        ''data
  194.  
  195.         SubDir$ = ""
  196.  
  197.         ClearCopyList
  198.  
  199.  
  200.         IF GetListItem(CHECKSTATES$, MINIMAL) = "ON" THEN
  201.             AddFilesToCopyList MINIMAL
  202.         END IF
  203.         IF GetListItem(CHECKSTATES$, STANDARD) = "ON" THEN
  204.             AddFilesToCopyList MINIMAL
  205.             AddFilesToCopyList STANDARD
  206.         END IF
  207.         IF GetListItem(CHECKSTATES$, FULL) = "ON" THEN
  208.             AddFilesToCopyList MINIMAL
  209.             AddFilesToCopyList STANDARD
  210.             AddFilesToCopyList FULL
  211.         END IF
  212.  
  213.         ''Add system files
  214.         AddSectionFilesToCopyList "SystemFiles", SOURCE$, GetWindowsSysDir
  215.  
  216.         ''Copy files
  217.         CopyFilesInCopyList
  218.  
  219.         ''System profile settings
  220.         CreateSysIniKeyValue MakePath (GetWindowsDir, "SYSTEM.INI"), "386Enh", "UniqueDOSPSP", "TRUE" , cmoOverwrite
  221.         IF GetWindowsMajorVersion () = 3 THEN
  222.             CreateSysIniKeyValue MakePath (GetWindowsDir, "SYSTEM.INI"), "386Enh", "device", "VSHARE.386" , cmoNone
  223.         ENDIF
  224.  
  225.         ''Update profile settings
  226.         profile$ = MakePath (GetWindowsDir, "MEMPHIS.INI")
  227.  
  228.         ''Btrieve settings
  229.         SubDir$ = MakePath (DEST$, "DATA\BTRIEVE.TRN")
  230.         btrv$ = "/m:64 /p:4096" + " /t:" + SubDir$
  231.         SubDir$ = ""
  232.         CreateIniKeyValue "WIN.INI", "Btrieve", "Options", btrv$, cmoOverwrite
  233.         btrv$ = ""
  234.  
  235.         ''Config settings
  236.         CreateIniKeyValue profile$, "Config", "Cache", "TRUE" , cmoOverwrite
  237.  
  238.         ''source and local cache settings
  239.         CreateIniKeyValue profile$, "Paths", "Local", DEST$ , cmoOverwrite
  240.         IF GetListItem(CHECKSTATES$, FULL) = "ON" THEN
  241.             CreateIniKeyValue profile$, "Paths", "Source", DEST$ , cmoOverwrite
  242.         ELSE
  243.             CreateIniKeyValue profile$, "Paths", "Source", SOURCE$ , cmoOverwrite
  244.         ENDIF
  245.         profile$ = ""
  246.  
  247.         ''create the program manager group and add the application
  248.         CreateProgmanGroup PMGROUP$, "", cmoNone
  249.         ShowProgmanGroup PMGROUP$, 1, cmoNone
  250.         IF GetListItem (CHECKSTATES$, MINIMAL) = "ON" THEN
  251.             AppPath$ = MakePath (SOURCE$, "MEMPHIS.EXE")
  252.         ELSE
  253.             AppPath$ = MakePath (DEST$, "MEMPHIS.EXE")
  254.         ENDIF
  255.         IcoPath$ = MakePath (DEST$, "MEMPHIS.ICO")
  256.         CreateProgmanItem PMGROUP$, "Memphis Math", AppPath$, IcoPath$, cmoOverwrite
  257.         AppPath$ = ""
  258.         IcoPath$ = ""
  259.  
  260.  
  261. QUIT:
  262.         ON ERROR GOTO ERRQUIT
  263.  
  264.         IF ERR = 0 THEN
  265.                 dlg% = EXITSUCCESS
  266.         ELSEIF ERR = STFQUIT THEN
  267.                 dlg% = EXITQUIT
  268.         ELSE
  269.                 dlg% = EXITFAILURE
  270.         END IF
  271. QUITL1:
  272.         sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  273.         IF sz$ = "REACTIVATE" THEN
  274.                 GOTO QUITL1
  275.         END IF
  276.         UIPop 1
  277.  
  278.         END
  279.  
  280. ERRQUIT:
  281.         i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  282.         END
  283.  
  284.  
  285.  
  286. GETPATH:
  287.         SetSymbolValue "EditTextIn", DEST$
  288.         SetSymbolValue "EditFocus", "END"
  289. GETPATHL1:
  290.         sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  291.  
  292.         IF sz$ = "CONTINUE" THEN
  293.                 olddest$ = DEST$
  294.                 DEST$ = GetSymbolValue("EditTextOut")
  295.  
  296.                 ''Validate new path.
  297.                 IF IsDirWritable(DEST$) = 0 THEN
  298.                         GOSUB BADPATH
  299.                         GOTO GETPATHL1
  300.                 END IF
  301.                 UIPop 1
  302.  
  303.                 ''Truncate display if too long.
  304.                 IF LEN(DEST$) > 23 THEN
  305.                         ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  306.                 ELSE
  307.                         ReplaceListItem DRIVETEXT$, 7, DEST$
  308.                 END IF
  309.  
  310.                 ''Recalc if path changed.
  311.                 IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  312.                         RecalcPath
  313.                         SetDriveStatus
  314.                 END IF
  315.  
  316.                 olddest$ = ""
  317.                 GOTO CUSTINST
  318.         ELSEIF sz$ = "REACTIVATE" THEN
  319.                 RecalcPath
  320.                 SetDriveStatus
  321.                 GOTO GETPATHL1
  322.         ELSEIF sz$ = "EXIT" THEN
  323.                 GOSUB ASKQUIT
  324.                 GOTO GETPATHL1
  325.         ELSE
  326.                 UIPop 1
  327.                 GOTO CUSTINST
  328.         END IF
  329.  
  330.  
  331.  
  332. TOOBIG:
  333.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  334.     IF sz$ = "REACTIVATE" THEN
  335.                 RecalcPath
  336.                 SetDriveStatus
  337.         GOTO TOOBIG
  338.         END IF
  339.     UIPop 1
  340.     RETURN
  341.  
  342.  
  343.  
  344. BADPATH:
  345.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  346.         IF sz$ = "REACTIVATE" THEN
  347.         RecalcPath
  348.                 SetDriveStatus
  349.                 GOTO BADPATH
  350.         END IF
  351.     UIPop 1
  352.     RETURN
  353.  
  354.  
  355.  
  356. ASKQUIT:
  357.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  358.  
  359.         IF sz$ = "EXIT" THEN
  360.         UIPopAll
  361.         ERROR STFQUIT
  362.     ELSEIF sz$ = "REACTIVATE" THEN
  363.         GOTO ASKQUIT
  364.     ELSE
  365.         UIPop 1
  366.     END IF
  367.         RETURN
  368.  
  369.  
  370.  
  371. '**
  372. '** Purpose:
  373. '**     Adds the specified files to the copy list.
  374. '** Arguments:
  375. '**     ftype%  - type of files to add
  376. '** Returns:
  377. '**     none.
  378. '*************************************************************************
  379. SUB AddFilesToCopyList (ftype%) STATIC
  380.  
  381.         IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  382.                 SrcDir$ = GetSymbolValue ("STF_SRCDIR")
  383.                 DestDir$ = DEST$
  384.                 IF ftype% = MINIMAL THEN
  385.                         AddSectionFilesToCopyList "DataFiles", SrcDir$, DestDir$
  386.                 ELSEIF ftype% = STANDARD THEN
  387.                         AddSectionFilesToCopyList "DataFiles", SrcDir$, DestDir$
  388.                         AddSectionFilesToCopyList "AppFiles", SrcDir$, DestDir$
  389.                         AddSectionFilesToCopyList "StdResourceFiles", SrcDir$, DestDir$
  390.                 ELSEIF ftype% = FULL THEN
  391.                         AddSectionFilesToCopyList "DataFiles", SrcDir$, DestDir$
  392.                         AddSectionFilesToCopyList "AppFiles", SrcDir$, DestDir$
  393.                         AddSectionFilesToCopyList "StdResourceFiles", SrcDir$, DestDir$
  394.                         AddSectionFilesToCopyList "ResourceFiles", SrcDir$, DestDir$
  395.                 END IF
  396.                 SrcDir$ = ""
  397.                 DestDir$ = ""
  398.         END IF
  399. END SUB
  400.  
  401.  
  402. '**
  403. '** Purpose:
  404. '**     Recalculates disk space for the given option files and sets
  405. '**     the status info symbol "StatusItemsText".
  406. '** Arguments:
  407. '**     ftype% - type of files to add
  408. '**
  409. '** Returns:
  410. '**     none.
  411. '*************************************************************************
  412. SUB RecalcOptFiles (ftype%) STATIC
  413.         CursorSave% = ShowWaitCursor()
  414.         ClearCopyList
  415.         AddFilesToCopyList ftype%
  416.  
  417.         fExtra% = 0
  418.  
  419.         IF ftype% = STANDARD THEN
  420.                 ListSym$ = APPNEEDS$
  421.         ELSEIF ftype% = FULL THEN
  422.                 ListSym$ = RESNEEDS$
  423.         ELSEIF ftype% = MINIMAL THEN
  424.             ListSym$ = REQNEEDS$
  425.         END IF
  426.  
  427.         ''Add extra cost to Windows drive for ini/progman, ctl3d, Video for Windows RT.
  428.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  429.         ReplaceListItem EXTRACOSTS$, ndrive%, "1000000"
  430.         fExtra% = 1
  431.  
  432.         StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  433.  
  434.         cost& = 0
  435.         FOR i% = 1 TO 26 STEP 1
  436.                 cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  437.         NEXT i%
  438.         ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " KB"
  439.  
  440.         IF StillNeed& > 0 THEN
  441.                 ReplaceListItem BIGLIST$, ftype%, "YES"
  442.         ELSE
  443.                 ReplaceListItem BIGLIST$, ftype%, ""
  444.         END IF
  445.  
  446.         IF fExtra% THEN
  447.                 ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  448.         END IF
  449.         RestoreCursor CursorSave%
  450.         ListSym$ = ""
  451. END SUB
  452.  
  453.  
  454. '**
  455. '** Purpose:
  456. '**     Recalculates disk space and sets option status info according
  457. '**     to the current destination path.
  458. '** Arguments:
  459. '**     none.
  460. '** Returns:
  461. '**     none.
  462. '*************************************************************************
  463. SUB RecalcPath STATIC
  464.  
  465.         CursorSave% = ShowWaitCursor()
  466.  
  467.         RecalcOptFiles MINIMAL
  468.         RecalcOptFiles STANDARD
  469.         RecalcOptFiles FULL
  470.  
  471.         RestoreCursor CursorSave%
  472. END SUB
  473.  
  474.  
  475. '**
  476. '** Purpose:
  477. '**     Sets drive status info according to latest disk space calcs.
  478. '** Arguments:
  479. '**     none.
  480. '** Returns:
  481. '**     none.
  482. '*************************************************************************
  483. SUB SetDriveStatus STATIC
  484.  
  485.         drive$ = MID$(DEST$, 1, 1)
  486.         ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  487.         cost& = VAL(GetListItem(REQNEEDS$, ndrive%)) + VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(RESNEEDS$, ndrive%))
  488.         free& = GetFreeSpaceForDrive(drive$)
  489.         ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  490.         ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " KB"
  491.         ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " KB"
  492.  
  493. '        IF drive$ = WINDRIVE$ THEN
  494. '                ReplaceListItem DRIVETEXT$, 4, ""
  495. '                ReplaceListItem DRIVETEXT$, 5, ""
  496. '                ReplaceListItem DRIVETEXT$, 6, ""
  497. '        ELSE
  498.                 ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  499.                 cost& = VAL(GetListItem(REQNEEDS$, ndrive%)) + VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(RESNEEDS$, ndrive%))
  500. '                IF cost& = 0 THEN
  501. '                        ReplaceListItem DRIVETEXT$, 4, ""
  502. '                        ReplaceListItem DRIVETEXT$, 5, ""
  503. '                        ReplaceListItem DRIVETEXT$, 6, ""
  504. '                ELSE
  505.                         free& = GetFreeSpaceForDrive(WINDRIVE$)
  506.                         ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  507.                         ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " KB"
  508.                         ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " KB"
  509. '                END IF
  510. '        END IF
  511. END SUB
  512.  
  513.  
  514. '**
  515. '** Purpose:
  516. '**     Appends a file name to the end of a directory path,
  517. '**     inserting a backslash character as needed.
  518. '** Arguments:
  519. '**     szDir$  - full directory path (with optional ending "\")
  520. '**     szFile$ - filename to append to directory
  521. '** Returns:
  522. '**     Resulting fully qualified path name.
  523. '*************************************************************************
  524. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  525.         IF szDir$ = "" THEN
  526.                 MakePath = szFile$
  527.         ELSEIF szFile$ = "" THEN
  528.                 MakePath = szDir$
  529.         ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  530.                 MakePath = szDir$ + szFile$
  531.         ELSE
  532.                 MakePath = szDir$ + "\" + szFile$
  533.         END IF
  534. END FUNCTION
  535.  
  536.